﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PSL.Lexer;

namespace ParserUnitTest
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TokenizerHelperTest()
        {
            string test1 = TokenizerHelper.GetStringUntilChars("Test -123", " ", Environment.NewLine);
            Assert.AreEqual("Test", test1);

            test1 = TokenizerHelper.GetStringUntilChars("Test -123", " ", Environment.NewLine);
            Assert.AreEqual("Test", test1);

            test1 = TokenizerHelper.GetStringUntilChars("", " ", Environment.NewLine);
            Assert.AreEqual("", test1);

            test1 = TokenizerHelper.RemoveFromLineStart("print -param1:VALUE", "print");
            Assert.AreEqual("-param1:VALUE", test1.Trim());

            test1 = TokenizerHelper.RemoveFromLineStart("print -param1:VALUE", "----------------------------------------------------");
            Assert.AreEqual("", test1.Trim());

            test1 = TokenizerHelper.GetStrintBetweenChars("print -param1:VALUE", '-', ':');
            Assert.AreEqual("param1", test1.Trim());

            test1 = TokenizerHelper.GetNextDelegate("{var -getName:value} -secondParam");
            Assert.AreEqual("var -getName:value", test1);

            test1 = TokenizerHelper.GetNextDelegate("{var -getName:\"\\{123\\}\"} -secondParam");
            Assert.AreEqual("var -getName:\"\\{123\\}\"", test1);

            Parser tokenizer = new Parser(null);
            //test1 = tokenizer.ParseValue("2+3 -nextParam:", null);

            test1 = tokenizer.ParseValue("3*8+7 -nextParam:", null);

            bool test2 = TokenizerHelper.IsDigit('a');
            Assert.AreEqual(false, test2);

            test2 = TokenizerHelper.IsDigit('1');
            Assert.AreEqual(true, test2);
        }

        [TestMethod]
        public void LexerMainTest()
        {
            /*PSL.PSLEngine runtime = new PSL.PSLEngine();

            runtime.Execute
                (
                    "# Simple Comment" + Environment.NewLine +
                    "print -param1:abc -text:{var -name:\"my\\\"var\"}" + Environment.NewLine +
                    "print -param1:abc -text:{var -name:\"my\\\"var\"}" + Environment.NewLine +
                    "if -condition:true" + Environment.NewLine +
                    "   print -param1:abc -text:{var -name:\"my\\\"var\"}" + Environment.NewLine +
                    "else" + Environment.NewLine +
                    "   print -param1:abc -text:{var -name:\"my\\\"var\"}" + Environment.NewLine +
                    "end"
                );*/
        }
    }
}
